package day9;

import javax.management.monitor.Monitor;

public class AccountManger {

	// 余额（当前账户有多少钱）
	private Double balance;
	// 账号
	private Integer number;
	
	public AccountManger() {
		super();
	}

	public AccountManger(Double balance, Integer number) {
		super();
		this.balance = balance;
		this.number = number;
	}
	
	// 存钱
	public void doposite(Double money) {
		balance += money;
	}
	
	// 取钱
	public void withdraw(Double moneny) throws MeiQianException  {
		if (balance >= moneny) {
			balance -= moneny;
		} else {// 余额不足，抛出异常
			double needMoney = moneny - balance;
			throw new MeiQianException(needMoney);
		}
	}

	public Double getBalance() {
		return balance;
	}

	public void setBalance(Double balance) {
		this.balance = balance;
	}

	public Integer getNumber() {
		return number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

	@Override
	public String toString() {
		return "AccountManger [balance=" + balance + ", number=" + number + "]";
	}
	
	
	
}
